
    <div class="dux-box">
        <div class="box-side">
            <div class="uk-card uk-card-small uk-card-default dux-panel">
                <ul class="dux-menu">
                    <li><a href="{url('index')}">基本设置</a></li>
                    <li class="active"><a href="{url('apply')}">申请设置</a></li>
                    <li><a href="{url('level')}">升级设置</a></li>
                    <li><a href="{url('qrcode')}">二维码设置</a></li>
                    <li><a href="{url('notice')}">消息设置</a></li>
                </ul>
            </div>
        </div>

        <div class="box-body">
            <div class="uk-card uk-card-small uk-card-default dux-panel">
                <div class="uk-card-header">申请设置</div>
                <div class="uk-card-body">
                    <form class="dux-form uk-form  uk-form-horizontal" method="post" action="{url()}"
                          data-dux="form-bind">
                        <fieldset>
                            <div class="uk-form-group">
                                <label class="uk-form-label">申请条件</label>
                                <div class="uk-form-controls">
                                    <select name="apply_type" data-sel="{$info.apply_type}" data-value="{$info.apply_where.data}" data-type="{$info.apply_where.type}">
                                        <option value="1" {$info.apply_type == 1 ? 'selected' : ''}>申请</option>
                                        <option value="2" {$info.apply_type == 2 ? 'selected' : ''}>消费次数</option>
                                        <option value="3" {$info.apply_type == 3 ? 'selected' : ''}>消费金额</option>
                                        <option value="4" {$info.apply_type == 4 ? 'selected' : ''}>购买商品</option>
                                    </select>
                                    <div class="uk-form-help">推广佣金比例请在推广等级中设置</div>
                                </div>
                            </div>

                            <div id="apply-where">

                            </div>

                            <div class="uk-form-group">
                                <label class="uk-form-label">申请审核</label>
                                <div class="uk-form-controls uk-form-controls-text">

                                        <div class="uk-grid">
                                        <label >
                                            <!--if{$info['apply_check']}-->
                                            <input name="apply_check" value="1" checked="checked" type="radio">
                                            <!--{else}-->
                                            <input name="apply_check" value="1" type="radio">
                                            <!--{/if}-->
                                            需要
                                        </label>

                                        <label >
                                            <!--if{!$info['apply_check']}-->
                                            <input name="apply_check" checked="checked" value="0" type="radio">
                                            <!--{else}-->
                                            <input name="apply_check" value="0" type="radio">
                                            <!--{/if}-->
                                            不需要
                                        </label></div>
                                </div>
                            </div>


                            <div class="uk-form-group">
                                <div class="uk-form-controls">
                                    <button class="uk-button uk-button-primary" type="submit">保存</button>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </div>

<script type="text/html" id="tpl-2">
    <div class="uk-form-group">
        <label class="uk-form-label">消费次数</label>
        <div class="uk-form-controls">
            <input type="number" name="apply_where[data]" value="{{ d.value }}" required>
            <div class="uk-form-help">消费达到设置次数即可自动成为推广商</div>
        </div>
    </div>
    <div class="uk-form-group">
        <label class="uk-form-label">消费统计方式</label>
        <div class="uk-form-controls uk-form-controls-text">
            <div class="uk-grid">
                <label >
                    <input name="apply_where[type]" value="1"  {{ d.type ? 'checked' : '' }} type="radio">
                    付款后
                </label>

                <label >
                    <input name="apply_where[type]" value="0"  {{ !d.type ? 'checked' : '' }} type="radio">
                    完成后
                </label></div>
        </div>
    </div>
</script>

<script type="text/html" id="tpl-3">
    <div class="uk-form-group">
        <label class="uk-form-label">消费金额</label>
        <div class="uk-form-controls">
            <input type="number" name="apply_where[data]" value="{{ d.value }}" required>
            <div class="uk-form-help">消费累计达到设置金额即可自动成为推广商</div>
        </div>
    </div>
    <div class="uk-form-group">
        <label class="uk-form-label">消费统计方式</label>
        <div class="uk-form-controls uk-form-controls-text">
            <div class="uk-grid">
                <label >
                    <input name="apply_where[type]" value="1"  {{ d.type ? 'checked' : '' }} type="radio">
                    付款后
                </label>

                <label >
                    <input name="apply_where[type]" value="0"  {{ !d.type ? 'checked' : '' }} type="radio">
                    完成后
                </label></div>
        </div>
    </div>
</script>

<script type="text/html" id="tpl-4">
    <div class="uk-form-group">
        <label class="uk-form-label">商品货号</label>
        <div class="uk-form-controls">
            <input type="text" name="apply_where[data]" value="{{ d.value }}" placeholder="请输入指定商品货号" required>
            <div class="uk-form-help">消费指定商品后即可自动成为推广商</div>
        </div>
    </div>
    <div class="uk-form-group">
        <label class="uk-form-label">消费统计方式</label>
        <div class="uk-form-controls uk-form-controls-text">
            <div class="uk-grid">
                <label >
                    <input name="apply_where[type]" value="1"  {{ d.type ? 'checked' : '' }} type="radio">
                    付款后
                </label>

                <label >
                    <input name="apply_where[type]" value="0"  {{ !d.type ? 'checked' : '' }} type="radio">
                    完成后
                </label></div>
        </div>
    </div>
</script>

<script>
    Do('base', 'tpl', function () {
        $('select[name=apply_type]').on('change', function () {
            var val = $(this).val(),data = $(this).data(),layout = $('#apply-where');
            var tpl = $('#tpl-' + val).html();
            if(!tpl) {
                layout.html('');
                return true;
            }
            if(data.sel != val) {
                data = {
                    value : '',
                    type : 1
                };
            }
            laytpl(tpl).render(data, function(html){
                layout.html(html);
            });
        });
        $('select[name=apply_type]').change();
    });
</script>